package com.cg.mapper;

import com.cg.entity.City;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cg.result.CityVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 基础表-省市区 Mapper 接口
 * </p>
 *
 * @author lhy
 * @since 2024-12-26
 */
@Mapper
public interface CityMapper extends BaseMapper<City> {
    @Select("SELECT id, name, parent_id AS parentId, level FROM city ORDER BY level, parent_id, name")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "parentId", column = "parentId"),
            @Result(property = "level", column = "level")
    })
    List<CityVO> selectAllCities();
}
